package com.bi.rapidfloatingactionbutton;

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.wangjie.androidbucket.utils.ABTextUtil;
import com.wangjie.androidbucket.utils.imageprocess.ABShape;
import com.wangjie.rapidfloatingactionbutton.RapidFloatingActionButton;
import com.wangjie.rapidfloatingactionbutton.RapidFloatingActionHelper;
import com.wangjie.rapidfloatingactionbutton.RapidFloatingActionLayout;
import com.wangjie.rapidfloatingactionbutton.contentimpl.labellist.RFACLabelItem;
import com.wangjie.rapidfloatingactionbutton.contentimpl.labellist.RapidFloatingActionContentLabelList;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity  implements RapidFloatingActionContentLabelList.OnRapidFloatingActionContentLabelListListener {
    private RapidFloatingActionLayout rfaLayout;
    private RapidFloatingActionButton rfaBtn;
    private RapidFloatingActionHelper rfabHelper;
    private boolean f=true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        rfaBtn= (RapidFloatingActionButton) findViewById(R.id.activity_main_rfab);
        rfaLayout= (RapidFloatingActionLayout) findViewById(R.id.activity_main_rfal);


        RapidFloatingActionContentLabelList rfaContent = new RapidFloatingActionContentLabelList(MainActivity.this);
            rfaContent.setOnRapidFloatingActionContentLabelListListener(this);
            List<RFACLabelItem> items = new ArrayList<>();
            items.add(new RFACLabelItem<Integer>()
                            .setLabel("Github: wangjiegulu")
                            .setResId(R.mipmap.ico_test_d)
                            .setIconNormalColor(0xffd84315)
                            .setIconPressedColor(0xffbf360c)
                            .setWrapper(0)
            );
            items.add(new RFACLabelItem<Integer>()
                            .setLabel("tiantian.china.2@gmail.com")
                            .setResId(R.mipmap.ico_test_c)
                            .setIconNormalColor(0xff4e342e)
                            .setIconPressedColor(0xff3e2723)
                            .setLabelColor(Color.WHITE)
                            .setLabelSizeSp(14)
                            .setLabelBackgroundDrawable(ABShape.generateCornerShapeDrawable(0xaa000000, ABTextUtil.dip2px(MainActivity.this, 4)))
                            .setWrapper(1)
            );
            items.add(new RFACLabelItem<Integer>()
                            .setLabel("WangJie")
                            .setResId(R.mipmap.ico_test_b)
                            .setIconNormalColor(0xff056f00)
                            .setIconPressedColor(0xff0d5302)
                            .setLabelColor(0xff056f00)
                            .setWrapper(2)
            );
            items.add(new RFACLabelItem<Integer>()
                            .setLabel("Compose")
                            .setResId(R.mipmap.ico_test_a)
                            .setIconNormalColor(0xff283593)
                            .setIconPressedColor(0xff1a237e)
                            .setLabelColor(0xff283593)
                            .setWrapper(3)
            );
            rfaContent
                    .setItems(items)
                    .setIconShadowRadius(ABTextUtil.dip2px(MainActivity.this, 5))
                    .setIconShadowColor(0xff888888)
                    .setIconShadowDy(ABTextUtil.dip2px(MainActivity.this, 5))
            ;
            rfabHelper = new RapidFloatingActionHelper(
                    MainActivity.this,
                    rfaLayout,
                    rfaBtn,
                    rfaContent
            ).build();
        }

        @Override
        public void onRFACItemLabelClick(int position, RFACLabelItem item) {
            Toast.makeText(this, "clicked label: " + position, Toast.LENGTH_SHORT).show();
            rfabHelper.toggleContent();
        }

        @Override
        public void onRFACItemIconClick(int position, RFACLabelItem item) {
            Toast.makeText(this, "clicked icon: " + position, Toast.LENGTH_SHORT).show();
            rfabHelper.toggleContent();
        }

    }
